<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ page import="java.util.*" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <meta name="viewport" content="width=device-width,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
  <title>用户信息</title>
  <style>
    .table {
        width: 100%;
        border-collapse: collapse;
        text-align: center;
    }
    .table td {
        border:1px solid black;
    }
    .search {
        
    }
  </style>
  <script>
  </script>
</head>
<body>
  <a href="StudentServlet?action=add&role=${role1}">添加</a>
  <table class="table">
    <!-- 
    <tr class="search">
      <td><input/></td>
      <td><input/></td>
      <td><input/></td>
      <td><input/></td>
      <td><input/></td>
      <td><input/></td>
      <td><input/></td>
      <td><input/></td>
      <td><input/></td>
      <td><input/></td>
      <td><input/></td>
      <td><input/></td>
      <td><input/></td>
    </tr>
     -->
    <!-- 
    <tr>
	  <td>账号</td>
      <td>姓名</td>
      <td>省</td>
      <td>市</td>
      <td>县</td>
      <td>学校</td>
      <td>院系</td>
      <td>专业</td>
      <td>课程</td>
      <c:if test="${role=='1'}">
      <td>成绩</td>
      </c:if>
      <td>性别</td>
      <td>年龄</td>
      <td>手机</td>
      <td>邮箱</td>
      <td>备注</td>
      <td>操作</td>
    </tr>
    <c:forEach var="user" items="${list}">
      <tr>
        <td>${user.account}</td>
        <td>${user.name}</td>
        <td>${user.province}</td>
        <td>${user.city}</td>
        <td>${user.county}</td>
        <td>${user.school}</td>
        <td>${user.college}</td>
        <td>${user.professional}</td>
        <td>${user.course}</td>
        <c:if test="${role=='1'}">
        <td>${user.grade}</td>
        </c:if>
        <td>${user.sex}</td>
        <td>${user.age}</td>
        <td>${user.phone}</td>
        <td>${user.mail}</td>
        <td>${user.note}</td>
        <td><a href="StudentServlet?action=edit&role=${role1}&id=${user.id}">编辑</a><a href="StudentServlet?action=deleteUser&role=${role}&id=${user.id}">删除</a></td>
      </tr>
    </c:forEach>
     -->
    <tr>
      <c:forEach var="property" items="${properties}">
        <td>${property.name}</td>
      </c:forEach>
      <td>操作</td>
    </tr>
    <%List<Map<String, Object>> properties = (List<Map<String, Object>>) request.getAttribute("properties"); 
    List<Map<String, Object>> list =  (List<Map<String, Object>>) request.getAttribute("list");
    for (Map<String, Object> user : list) {%>
    <tr>
        <%for (Map<String, Object> property : properties) {
            Object usertd = user.get(property.get("property").toString());
            if (usertd == null) {
                usertd = "";
            }%>
      <td><%=usertd %></td>
        <%}%>
      <td><a href="StudentServlet?action=edit&role=<%=user.get("role")%>&id=<%=user.get("id")%>">编辑</a><a href="StudentServlet?action=deleteUser&role=<%=user.get("role")%>&id=<%=user.get("id")%>">删除</a></td>
    </tr>
    <%}%>
     
  </table>
  <c:if test="${page>1}">
    <a href="StudentServlet?role=${role1}&page=${page-1}">上一页</a>
  </c:if>
  <c:if test="${page<pageNumber}">
    <a href="StudentServlet?role=${role1}&page=${page+1}">下一页</a>
  </c:if>
  <a>第 ${page}/${pageNumber} 页</a>
</body>
</html>